package com.caregiver.watch.business.user.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

/**
 * @Description: 用户聊天消息类型
 * @Author 疆戟
 * @Date 2025/8/31 14:46
 * @Version 1.0
 */
@Getter
@Schema(description = "用户聊天消息类型")
public enum UserChatMessageTypeEnum {

    /**
     * 0-文本 1-图片 2-语音
     */
    @Schema(description = "文本")
    TEXT(0, "文本"),
    @Schema(description = "图片")
    IMAGE(1, "图片"),
    @Schema(description = "语音")
    VOICE(2, "语音");
    private final Integer code;
    private final String desc;


    UserChatMessageTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static UserChatMessageTypeEnum pares(Integer code) {
        for (UserChatMessageTypeEnum value : UserChatMessageTypeEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return TEXT;
    }
}
